package engine.utils
{
	import ash.core.Entity;
	
	import engine.groups.other.CameraGroup;
	import engine.groups.other.CursorGroup;
	import engine.groups.Group;
	import engine.systems.control.cameraZoom.CameraZoom;
	import engine.systems.control.keyboardControl.KeyboardControl;
	import ash.core.Component;
	import engine.systems.spatial.spatialToMouse.SpatialToMouse;
	import engine.systems.update.timer.Timer;
	import engine.systems.update.timer.TimerSystem;
	import engine.systems.update.tween.Tween;
	import engine.systems.update.tween.TweenSystem;
	import engine.systems.update.update.Update;
	import engine.systems.update.update.UpdateSystem;

	public class SceneUtils
	{
		/*
		public function getGroupEntityComponent(componentClass:Class):*
		{
		var component:*;
		
		if(this._groupEntity)
		{
		component = this._groupEntity.get(componentClass);
		if(!component)
		{
		component = new componentClass();
		this._groupEntity.add(component);
		}
		}
		else
		{
		this._groupEntity = new Entity(this.name + "GroupEntity");
		this.addEntity(this._groupEntity);
		
		component = new componentClass();
		this._groupEntity.add(component);
		}
		
		return component;
		}
		
		public static const GROUP_ENTITY_NAME:String = "GroupEntity";
		
		public static function lockControl(group:Group, locked:Boolean = true):void
		{
			var entity:Entity;
			var component:Component;
			
			entity = group.getEntity(CameraGroup.CAMERA_ENTITY_NAME);
			if(entity)
			{
				component = entity.get(CameraZoom);
				if(component) component.locked = locked;
				
				component = entity.get(KeyboardControl);
				if(component) component.locked = locked;
			}
			
			entity = group.getEntity(CursorGroup.CURSOR_ENTITY_NAME);
			if(entity)
			{
				component = entity.get(SpatialToMouse);
				if(component) component.locked = locked;
			}
		}
		
		public static function update(group:Group):Update
		{
			group.addSystem(new UpdateSystem());
			return group.getGroupEntityComponent(group, Update);
		}
		
		public static function timer(group:Group):Timer
		{
			group.addSystem(new TimerSystem());
			return group.getGroupEntityComponent(group, Timer);
		}
		
		public static function tween(group:Group):Tween
		{
			group.addSystem(new TweenSystem());
			return group.getGroupEntityComponent(group, Tween);
		}*/
	}
}